<template>
  <div>
    <div class="crumbs">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>
          <span class="secondtitle">员工评价录入</span>

        </el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="container">
      <div class="handle-box">
        <el-row style="width: 500px;left: 300px;position: relative;text-color:black;display: block">
          <el-form ref="commentFrom" :rules="cm_rules" :model="commentFrom" label-width="80px" class="padding">
            <el-form-item label="员工编号" prop="worker_id">
              <el-input v-model="commentFrom.worker_id"></el-input>
            </el-form-item>

            <el-form-item label="hr编号" prop="staff_id">
              <el-input v-model="commentFrom.staff_id"></el-input>
            </el-form-item>

            <el-form-item label="奖惩" prop="symbol">
              <el-radio-group v-model="commentFrom.symbol" class="radio_s">
                <el-radio label="1">奖励</el-radio>
                <el-radio label="0">惩罚</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="详情" prop="detail">
              <el-input type="textarea" v-model="commentFrom.detail"></el-input>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="submitForm">提交</el-button>
              <el-button>取消</el-button>
            </el-form-item>
          </el-form>
        </el-row>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
import {pushWorkerComment} from "../../../../service/past/employeeComments";

export default {
  name: "employeeComents",
  data(){
    return {
      commentFrom: {
        worker_id:'',
        staff_id:'',
        symbol: '1',
        detail: ''
      },
      cm_rules: {
        worker_id: [
          {required: true, message: '请输入员工id', trigger: 'blur'}
        ],
        staff_id: [
          { required: true, message: '请输入hrid', trigger: 'blur' }
        ],
        // company_id: [{required: true, message: '请输入公司id', trigger: 'blur'}],
        symbol: [
          { required: true, message: '请选择奖惩', trigger: 'blur' }
        ],
        detail: [
          { required: true, message: '请输入详情', trigger: 'blur' }
        ]
      },
    }


  },

  methods: {
    Selct(index,indexpath) {
      console.log('------------------')
      console.log(index);
    },
    onSubmit() {
      console.log('submit!');
    },
    submitForm() {
      pushWorkerComment(this.commentFrom) .then((res)=>{
        if (res.code){
          this.commentFrom='',
            this.$message( {
              message: '添加成功',
              type: 'success'
            })
        }
      }).catch((err)=>{
        this.$message.error('添加失败，请联系管理员');
      })
    }
  },
  resetForm(formName)
  {
    this.$refs[formName].resetFields();
  }

}
</script>

<style>
.el-form-item__label{
  color: black;
  font-size: 14px;
}
</style>

